Python Hunting: A beginner's guide to programming and game building in Python for teens, tweens and newbies. by Brian Carling
Author:Brian Carling [Carling, Brian]
Language: eng
Format: epub
Publisher: UNKNOWN
Published: 2017-04-10T07:00:00+00:00
get_width() solves this problem. It measures the width of score at any point in time and we can use this value to position the score correctly.
We could have used the get_width function in other places. For example, in the space invader game we added a missile to the missiles list with the following line:
missiles.append(Missile(self.x+50))
That (self.x+50) is the position of the middle of the fighter. We happen to know the fighter is 100 pixels wide. But if we couldn't be bothered looking it up, or if we had several fighters of different widths, we could have written:
missiles.append(Missile(self.x+fighter_image.get_width()/2))
Similarly, when setting the y-position of the fighter we wrote:
screen.blit(fighter_image,(self.x,591))
But we had to work out that 591 by looking up the height of the screen and taking away the height of the fighter. We could have let Python do the maths with:
screen.blit(fighter_image,(self.x, screen.get_height()-fighter_image.get_height()))
The line we just wrote to blit the right hand score could look like this:
screen.blit(txt,(screen.get_width()-20-txt.get_width(),20))
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Ada | Ajax |
Assembly Language Programming | Borland Delphi |
C & C++ | C# |
CSS | Compiler Design |
Compilers | DHTML |
Debugging | Delphi |
Fortran | Java |
Lisp | Perl |
Prolog | Python |
RPG | Ruby |
Swift | Visual Basic |
XHTML | XML |
XSL |
Hello! Python by Anthony Briggs(9420)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9384)
The Mikado Method by Ola Ellnestam Daniel Brolund(9350)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7892)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7435)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7405)
Grails in Action by Glen Smith Peter Ledbrook(7327)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7157)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6002)
Kotlin in Action by Dmitry Jemerov(4681)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(3978)
Functional Programming in JavaScript by Mantyla Dan(3740)
Windows APT Warfare by Sheng-Hao Ma(3054)
Learning Java by Patrick Niemeyer & Daniel Leuck(2888)
Mastering Python for Finance by Weiming James Ma;(2873)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2864)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(2745)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2677)
Mastering Java 9 by Dr. Edward Lavieri(2583)